import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReverseWords {
	public static void main(String[] args) throws IOException {
		BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
		try {
			int N = Integer.parseInt(rdr.readLine());
			for(int n = 1; n <= N; n++) {
				String[] words = rdr.readLine().split(" ");
				System.out.print("Case #" + n + ":");
				for(int i = words.length - 1; i >= 0; i--)
					System.out.print(" " + words[i]);
				System.out.println();
			}
		} finally {
			rdr.close();
		}
	}
}
